
<div class="tpl-page-container tpl-page-header-fixed">

    <!--左侧-->

    <div class="tpl-content-wrapper">

        <div class="tpl-portlet-components">
            <div class="portlet-title">
                <div class="caption font-green bold">
                    <span class="am-icon-code"></span> 用户订单列表
                </div>

            </div>
            <div class="tpl-block">

                <div class="am-g" id="pbox">
                    <div class="am-u-sm-12">
                        <form class="am-form">
                            <table class="am-table am-table-striped am-table-hover table-main">
                                <thead>
                                <tr>
                                    <th class="table-check"><input type="checkbox" class="tpl-table-fz-check"></th>
                                    <th class="table-title">用户</th>
                                    <th class="table-title">订单id</th>
                                    <th class="table-title">订单金额</th>
                                    <th class="table-type">订单状态</th>
                                    <th class="table-author am-hide-sm-only">下单时间</th>
                                </tr>
                                </thead>
                                <tbody id="tbox">
                                <foreach name="data" item="v">
                                    <tr>
                                        <td><input type="checkbox"></td>
                                        <td>{$v.name}</td>
                                        <td><a href="#">{$v.order_id}</a></td>
                                        <td><a href="#">{$v.order_amount}</a></td>
                                        <td>
                                            <if condition="($v.order_status eq 0)">待处理
                                                <elseif condition="($v.order_status eq 200)"/>下单成功
                                                <elseif condition="($v.order_status eq 300)"/>已结算
                                                <else />提交失败
                                            </if>
                                        </td>
                                        <td class="am-hide-sm-only">{$v.order_time|date="Y-m-d H:i:s",###}</td>
                                    </tr>
                                </foreach>
                                </tbody>
                            </table>
                            <hr>
                        </form>
                        <div align="center" id="cd">{$page}</div>
                    </div>
                </div>
            </div>
            <div class="tpl-alert"></div>
        </div>
    </div>
</div>


<script src="__PUBLIC__/Admin/assets/js/jquery.min.js"></script>
<script src="__PUBLIC__/Admin/assets/js/amazeui.min.js"></script>
<script src="__PUBLIC__/Admin/assets/js/iscroll.js"></script>
<script src="__PUBLIC__/Admin/assets/js/app.js"></script>
</body>

</html>
<script src="__PUBLIC__/layer/jquery-1.7.2.min.js"></script>
<script>
    $('#startTime').click(function(){

        $('.am-datepicker').css({top:'250px'});

    })
    var object=Object();
    $('.search').on('click',function(){
        //获取搜索条件
        object['sel'] = $(".sel option:selected").val();
        object['startTime'] = $('#startTime').val();
        object['endTime'] = $('#endTime').val();
        object['order'] = $('#order').val();
        getShowTable();
    })
    $('#pbox').delegate('.page','click',function(){
        var p=$(this).attr('opt');
        getShowTable(p);
    });
    function getShowTable(p=1,fun='search1'){
        object['p']=p;
        $.ajax({
            type:'get',
            url:"__URL__/"+fun,
            data:object,
            dataType:'json',
            success:function(msg){
                var str='';
                $.each(msg.date,function(k,v){
                    str+='<tr>' +
                    '<td><input type="checkbox"></td>' +
                    '<td>'+v.name+'</td>' +
                    '<td><a href="#">'+v.order_id+'</a></td>' +
                    '<td><a href="#">'+v.order_amount+'</a></td>' +
                    '<td>'+ getStatus(v.order_status)+'</td>' +
                    '<td class="am-hide-sm-only">'+v.order_time+'</td>' +
                    '</tr>';
                });
                $('#tbox').html(str);
                $('#cd').html(msg.page);
            }
        })
    }
    //时间戳转换为标准时间
    function getLocalTime(nS) {
        return new Date(parseInt(nS) * 1000).toLocaleString().replace(/\//g, "-").substr(0,23);
    }

    //判断订单状态
    function getStatus(status){
        if(status == 0){
            return '待处理';
        }else if(status ==200){
            return '下单成功';
        }else if(status ==300){
            return '已结算';
        }else{
            return '提交失败';
        }
    }
    //这两个参数的含义：str：字符串，frontLen：前面保留位数
    function plusXing (str,frontLen) {
        var len = str.length-frontLen;
        var xing = '';
        for (var i=0;i<len;i++) {
            xing+='<font color="">*</font>';
        }
        return str.substring(0,frontLen)+xing;
    }
    //js字符串替换
    function getStr(str){
        if(str.length == 19){
            sub = str.substring(3,15);
            str1 = str.replace(sub,"<font color=''>"+'****'+"</font>");
            return str1;
        }else if(str.length == 18){
            sub = str.substring(3,12);
            str1 = str.replace(sub,"<font color=''>"+'****'+"</font>");
            return str1;
        }else if(str.length == 11){
            sub = str.substring(3,7);
            str1 = str.replace(sub,"<font color=''>"+'****'+"</font>");
            return str1;
        }else{
            return str;
        }
    }
</script>